use serde_derive::{Serialize, Deserialize};
use rust_admin2_common::{models::{RechargeRow as ModelRow}, json::JsonPager,};
use sqlx::{postgres::{PgRow}, row::Row,};
use num_traits::cast::ToPrimitive;
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct Recharge;

impl BackendModel<ModelRow> for Recharge {

    const TABLE_NAME: &'static str = "admins";
    const FIELDS: &'static str = "id, name, role_id, login_count, last_login, last_ip, status, created, updated, sort, remark";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            bill_no => String,
            user_id => i32,
            user_name => String,
            is_first => i16,
            status => i16,
            audit_admin_id => i32,
            audit_admin_name => String,
            audit_remark => String,
        }, {amount,}, {created,})
    }
}

impl Recharge {
    record_list!();
}
